<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * PHP Project Tracker
 *
 * CodeIgniter PHP Project Tracker Helper Functions
 *
 * Provides user-friendly functions to access project information
 * such as project releases, project changelogs, etc.
 *
 * @package 	CodeIgniter
 * @subpackage 	Helpers
 * @copyright	Copyright (c) 2009, Mahcuz, Inc.
 * @author 		Mark Skilbeck
 * @link		http://mahcuz.com/php-project-tracker
 */

/** ----------------------------------------------------------------------- **/
 
/**
 * Depending on the URI structure, this should point to
 * the segment in which the project alias will be held.
 * Generally 3.
 * @var		string
 */
DEFINE('PROJ_ALIAS_URI', 4);

/** ----------------------------------------------------------------------- **/

/**
 * get_project_name()
 *
 * Returns the project name for the given alias (via PROJ_ALIAS_URI)
 * or returns NULL on error.
 *
 * @access      public
 * @return      mixed       depends on whether the project exists.
 */
function get_project_name ()
{
    # Get our CI instance.
    $CI =& get_instance();
    
    # Do we have an alias? If not, no point in continuing.
    if ( $CI->uri->segment(PROJ_ALIAS_URI) === FALSE )
    {
        show_error('Cannot call <code><strong>get_project_name()</strong></code> without a project alias.<br /><br />
        Please check that you have <code><strong>PROJ_ALIAS_URI</strong></code> set to the correct position.<br /><br />
		It is currently set to <code>' . PROJ_ALIAS_URI . '</code>');
    }
    
    # The 'project' model needs to be loaded.
    if ( gettype ( $CI->project_model ) !== 'object' )
    {
        show_error('<code><strong>project</code></strong> is not loaded. PPT Helper Functions will not work.');
    }
    
    # Return the data given back to use from the project model.
    return $CI->project_model->name;
}


?>